package studio.raptor.ddal.dashboard.log.repository;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
import studio.raptor.ddal.dashboard.log.bo.ConnPoolLogExtendData;

import java.util.Date;
import java.util.List;

/**
 * Created by dell on 2018/1/4.
 */
@Repository
public interface ConnPoolLogRepository extends PagingAndSortingRepository<ConnPoolLogExtendData, String> {

    @Query("select dto from ConnPoolLogExtendData dto where acceptTime between ?1 and ?2 and appName=?3")
    public List<ConnPoolLogExtendData> findByAcceptTimeAndAppName(Date acceptBeginTime, Date acceptEndTime, String appName, Pageable pageable);

    @Query("select dto from ConnPoolLogExtendData dto where acceptTime between ?1 and ?2 and appName=?3 and dbuser=?4")
    public List<ConnPoolLogExtendData> findByAcceptTimeAndAppNameAndUsername(Date acceptBeginTime, Date acceptEndTime, String appName, String username, Pageable pageable);

}
